package io.renren.modules.wyzs.mobile_BillAdapterMoudle;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;


public class BillTemp {
    /// <summary>
    /// 类型ID
    /// </summary>
    private int ClassTypeID;
    public int getClassTypeID(){
        return this.ClassTypeID;
    }
    public void setClassTypeID(int ClassTypeID){
        this.ClassTypeID=ClassTypeID;
    }
    /// <summary>
    /// 类型
    /// </summary>
    private String ClassType;
    public String getClassType(){
        return this.ClassType;
    }
    public void setClassType(String ClassType){
        this.ClassType=ClassType;
    }
    /// <summary>
    /// 单据名称
    /// </summary>
    private String BillName;
    public String getBillName(){
        return this.BillName;
    }
    public void setBillName(String BillName){
        this.BillName=BillName;
    }
    /// <summary>
    /// 表名
    /// </summary>
    private String TableName;
    public String getTableName(){
        return this.TableName;
    }
    public void setTableName(String TableName){
        this.TableName=TableName;
    }

    /// <summary>
    /// 字段列表
    /// </summary>
    private HashMap<Integer, FieldTemp> Fields = new HashMap<Integer, FieldTemp>();
    public HashMap<Integer, FieldTemp> getFields(){
        return this.Fields;
    }
    public void setFields(HashMap<Integer, FieldTemp> Fields){
        this.Fields=Fields;
    }
    /// <summary>
    /// 单据体
    /// </summary>
    private HashMap<Integer, BillEntryTemp> Entrys = new HashMap<Integer, BillEntryTemp>();
    public HashMap<Integer, BillEntryTemp> getEntrys(){
        return this.Entrys;
    }
    public void setEntrys(HashMap<Integer, BillEntryTemp> Entrys){
        this.Entrys=Entrys;
    }

    /// <summary>
    /// 根据表序号获得字段列表
    /// </summary>
    /// <param name="page">表的序号0表示主表</param>
    /// <returns></returns>
    public List<FieldTemp> GetFieldsByPage(int page)
    {
        List<FieldTemp> fields = new LinkedList<FieldTemp>();

        for(FieldTemp Value:Fields.values()){
            if(Value.getPage()==page){
                fields.add(Value);
            }
        }

        return fields;
    }
    /// <summary>
    /// 获得字段模板
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    public FieldTemp GetFieldTempByName(String name)
    {
        for (FieldTemp Value: Fields.values())
        {
            if (Value.getName() == name)
            {
                return Value;
            }
        }
        return null;
    }
    /// <summary>
    /// 获得字段模板
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public FieldTemp GetFieldTempByID(Integer id)
    {
        if (Fields.containsKey(id))
        {
            return Fields.get(id);
        }
        return null;
    }
    /// <summary>
    /// 获得字段模板
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public FieldTemp GetFieldTempByKey(String key)
    {
        for (FieldTemp Value : Fields.values())
        {
            if (Value.getKey().equals(key) )
            {
                return Value;
            }
        }
        return null;
    }

}
